package com.servlet; /**
 * @author wzm
 * @create 2023-03-13 15:28
 */

import com.service.UserSerivce;
import com.service.impl.UserServiceImpl;
import com.utils.CodeUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/code.jpg")
public class CodeServlet extends HttpServlet {
    private UserSerivce userSerivce = new UserServiceImpl();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//        ServletOutputStream os = response.getOutputStream();
//        //生成验证码并相应给src
//        CodeUtils.outputVerifyImage(150,50,os,4);

  
        //生成验证码并相应给src
        String s = CodeUtils.outputVerifyImage(150, 50, response.getOutputStream(), 4);
        //存入Session方便注册时与用户输入的进行对比
        request.getSession().setAttribute("sessionCode",s);

    }



}
